package 线程.线程池定义;




import java.util.concurrent.*;

/**
 * @author zhoujie
 * @date 2020-08-03
 */
public class ThreadPollUtil {
    private static Integer coreSize;

    static {
        coreSize=  Runtime.getRuntime().availableProcessors()*2+1;
    }

    private static final ThreadPoolExecutor extendExecutor = new ThreadPoolExecutor(coreSize, coreSize, 60L, TimeUnit.SECONDS,
            new LinkedBlockingQueue<>(1024), new NamedThreadFactory("mypool-",true),
            new ThreadPoolExecutor.CallerRunsPolicy());

    public static void main(String[] args) {
       CompletableFuture.runAsync(()-> System.out.println("my thread poll"),extendExecutor).join();
    }
}
